// 测试显式隐式哪个优先级更高  显式优先级更高
function foo(){
    console.log(this.a);
}
var obj1={
    a:2,
    foo:foo,
}
var obj2={
    a:3,
    foo:foo
}
obj1.foo();//2
obj2.foo();//3
obj1.foo.call(obj2);//3
obj2.foo.call(obj1);//2
// new 绑定和隐式绑定哪个优先级更高 new绑定更高级
console.log('-------');
/*function fun(s){
    this.a=s;
    //return this.a;// 没有返回值返回undefined
   // console.log(this.a)
}
var obj3={
    a:2,
    fun:fun
}
var obj4={};
console.log(obj3.a);//2
 var f1=obj3.fun(1);
console.log(f1);//1
console.log(obj3.a);//1
obj3.fun.call(obj4,3);
console.log(obj4.a);//3
var bar=new obj3.fun(4);
console.log(obj3.a);//1
console.log(bar.a);//4
console.log(obj3.a);//1
*/
// new绑定和显式绑定哪个优先级更高
function foo(s){
    this.a=s;
}
var obj1={};
var bar=foo.bind(obj1);
bar(2);
console.log(obj1.a);//2
var baz=new bar(3);
console.log(obj1.a);//2
console.log(baz.a);//3  new 修改了this绑定